package team.seekers.hula.island.postComment.entity.dao;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springframework.beans.BeanUtils;
import team.seekers.hula.common.entity.BaseDO;
import team.seekers.hula.common.utils.BaseConvertUtils;
import team.seekers.hula.island.post.entity.dao.IslandPostDOField;
import team.seekers.hula.island.postComment.entity.vo.PostCommentReplyListVO;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author ekin
 * @Description GOOD
 * @mood happy
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName(IslandPostCommentReplyDOField.TABLE_NAME)
public class IslandPostCommentReplyDO extends BaseDO {
    private static final long serialVersionUID = 1L;

    @TableId(value = IslandPostCommentReplyDOField.ID, type = IdType.ASSIGN_ID)
    private String id;

    @TableField(IslandPostCommentReplyDOField.POST_COMMENT_ID)
    private String postCommentId;

    @TableField(IslandPostCommentReplyDOField.USER_ID)
    private String userId;

    @TableField(IslandPostCommentReplyDOField.NICKNAME)
    private String nickname;

    @TableField(IslandPostCommentReplyDOField.TO_ID)
    private String toId;

    @TableField(IslandPostCommentReplyDOField.TO_NICKNAME)
    private String toNickname;

    @TableField(IslandPostCommentReplyDOField.LAST_ID)
    private String lastId;

    /**
     * 给回复点赞的
     */
    @TableField(IslandPostCommentReplyDOField.LIKE_USERS_IDS)
    private String likeUserIds;

    @ApiModelProperty(value = "回复内容")
    @TableField(IslandPostCommentReplyDOField.CONTENT)
    private String content;

    @TableField(IslandPostCommentReplyDOField.FLOOR)
    private Integer floor;

    @TableField(IslandPostCommentReplyDOField.VISIBILITY)
    private Integer visibility;

    @TableField(IslandPostCommentReplyDOField.DELETED)
    @TableLogic(value = "0", delval = "1")
    private Integer deleted;

    @TableField(value = IslandPostCommentReplyDOField.GMT_CREATE, fill = FieldFill.INSERT)
    private Date gmtCreate;

    @TableField(value = IslandPostCommentReplyDOField.GMT_MODIFIED, fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;


    public static List<PostCommentReplyListVO> toListVOList(List<IslandPostCommentReplyDO> list){
        ArrayList<PostCommentReplyListVO> replyListVOS = new ArrayList<>();
        for (IslandPostCommentReplyDO replyDO : list) {
            PostCommentReplyListVO postCommentReplyListVO = new PostCommentReplyListVO();
            BeanUtils.copyProperties(replyDO,postCommentReplyListVO);
            List<String> userIds = BaseConvertUtils.stringToList(replyDO.getLikeUserIds());
            postCommentReplyListVO.setLikeUserIds(userIds);
            replyListVOS.add(postCommentReplyListVO);
        }
        return replyListVOS;
    }


}
